Repository navigation
fix(resume-checker): show real copy instead of API error codes, and start a test suite - #32
Merged
Merged
Conversation
The review page called `res.json()` on every failed response. Two problems,
both visible to users in the red `ErrorBadge`, which renders `error.message`
verbatim:
- A non-JSON body threw inside the mutation, so the badge showed the parse
error ("Unexpected token 'R'..."). The dropzone has no size cap, so any
resume over Vercel's 4.5MB function payload limit gets a plain-text 413
from the platform and hits this. Gateway timeouts on a 300s route do too.
- Since a8e92c1 the route answers with stable codes, so the badge showed
users the literal strings "MissingURL" and "GradingError".
`getErrorMessage` maps the codes the route can answer with to Spanish copy,
gives 413 its own message, and falls back to the generic one for everything
else. Nothing from the response body reaches the badge any more.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EeCD8BnUFcRVxrdxKfHnKE
vitest was already a devDependency with nothing to run. Add the config, a `test` script, and the first tests: the grade route's status/code contract (4xx for crawler GETs and bad uploads, no raw message on the 500 path) and the resume-checker error mapping. Tests live in `tests/` rather than beside the route because anything under `src/pages` is a page — a co-located `grade.test.ts` would be served at /api/grade.test and fail the build for want of a default export. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EeCD8BnUFcRVxrdxKfHnKE
Nothing ran the suite. Build stays out of it — Vercel already builds every PR. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EeCD8BnUFcRVxrdxKfHnKE
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Supersedes #12, which was opened against a base from April and whose route changes have since been overtaken by a8e92c1. Rewritten on top of current
main.What changed
The review page showed users raw strings from the API.
review.tsxcalledres.json()on every failed response and rendered the result straight into the redErrorBadge(which printserror.message). Two live failure modes:413from the platform before the route runs —res.json()threw, and the badge showedUnexpected token 'R'.... Gateway timeouts on the 300s route behaved the same way.MissingURLandGradingError.getErrorMessageinsrc/resume-checker/utils.tsmaps the codes the route can answer with to Spanish copy, gives 413 its own message, and falls back to the generic one otherwise. Nothing from the response body reaches the badge — deliberately no raw-text fallback, since that just re-leaks a 504 HTML page into the UI.Test suite.
vitestwas already a devDependency with nothing to run. Addedvitest.config.ts, atestscript, and 15 tests: the/api/gradestatus/code contract (4xx for crawler GETs and bad uploads, no raw message on the 500 path) and the error mapping. Tests live intests/rather than beside the route — anything undersrc/pagesis a page, so a co-locatedgrade.test.tswould be served at/api/grade.testand fail the build for want of a default export.CI. Nothing ran the suite. Lint + typecheck + test on every PR; build stays out since Vercel already builds each one.
What #12 had that this drops
Its
grade.tsdiff is superseded by a8e92c1, which does the same 4xx normalization and goes further by returning a stableGradingErrorinstead ofe.message— #12 still didsendJsonError(res, 500, e.message), so rebasing it would have reintroduced the leak. Also dropped its ~150 lines of tests that only exercised its own mock helpers, and itsexport default function GradeRouteTestHarness() {}workaround, which thetests/layout makes unnecessary.#12's "known issue" (React 19.2.0 vs 19.2.3 breaking the build) no longer applies — both are pinned at 19.2.3.
Testing
bun run test— 15/15 pass. Mutation-checked: reverting the 405 guard or theGradingErrorcode fails 2 tests.bunx tsc --noEmit,bun run lint,bunx prettier --check— clean.bun run build— passes;/api/grade.testcorrectly absent from the route list.🤖 Generated with Claude Code
https://claude.ai/code/session_01EeCD8BnUFcRVxrdxKfHnKE